package com.stu.thread.demo;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @projectName: learn_used_code
 * @packageName: com.stu.thread.demo
 * @className: com.stu.thread.demo-> TestComputerTask
 * @createDate: 2022-03-23 12:45
 * @author: ZhangSheng
 * @version: 1.0
 * @description:
 */
public class TestComputerTask {


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture.runAsync(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("A");
            }
        }).thenRunAsync(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("B");
            }
        }).thenRunAsync(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(500L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("C");
            }
        }).get();

    }
}
